<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
  <ws ref="w" :users.sync="onlines" :msgs.sync="msgs"></ws>
  <div style="display: flex;justify-content: center; margin-top: 100px">
    <div>
      用户: <input type="text" v-model="id"><button @click="login">连接</button><br>
      消息: <input type="text" v-model="text"><button @click="send">发送</button>
    </div>
  </div>
  <div style="width: 50%; margin: auto">
    <h3>在线用户</h3>
    <ol>
      <li v-for="o in onlines">{{o.cname}}
        <img :src="o.head" alt="">
      </li>
    </ol>
    <h4>消息列表</h4>
    <ul>
      <li v-for="m in msgs">{{m.content}}</li>
    </ul>
  </div>

</div>
<script src="http://47.106.66.89:8080/js/vue.min.js"></script>
<script src="http://47.106.66.89:8080/js/axios.min.js"></script>
<link  href="http://47.106.66.89:8080/js/ele-2.15.7/theme-chalk/index.css" rel="stylesheet">
<script src="http://47.106.66.89:8080/js/ele-2.15.7/index.js"></script>
<script src="/js/ws.js"></script>
<script>
  var v = new Vue({
    el : "#app",
    data : {id:"",text:"", onlines: [], msgs: [],},
    created() {},
    methods : {
      login(){
        this.$refs.w.login(this.id);
      },
      send(){
        this.$refs.w.send(this.text);
        this.text = "";
      }
    }
  })
</script>
</body>
</html>
